/*
 * Created on 13 avr. 2005
 *
 */
package communication.pack;

import objects.Station;



/**
 * @author gngoundj
 * @since 13/04/05
 * TSMPackage modelizes package which is sent during a comunication
 * in the ad hoc mode
 */

public abstract class SMPackage {
	
    /**
     * size of a DataPackage heading
     */
    public final static int DATAHEADINGSIZE=16;
    
    /**
     * size of HelloAODV package
     */
    public final static int HELLOAODVSIZE=8; //unite: octet
    
    /**
     * size of Rerr package
     */
    public final static int RERRSIZE=12;
    
    /**
     * size of ROUTEREPLY package
     */
    public final static int ROUTEREPLYSIZE=25;
    
    /**
     * size of RouteRequest package
     */
    
    
    public final static int ROUTEREQUESTSIZE=24;
    
    
    /**
     * size of TCPackage package
     */
    public final static int TCPACKAGESIZE=30;
    

    
    /**
     * sizes of different packages used exclusively in the sensor network
     */
    public final static int INTEREST = 15;

    public final static int REINFORCEMENT = 15;

    public final static int SENSORDATA = 30;

    public final static int SINKACK = 12;
    

    /**
     * To set up a TimeToLive for a package, we'll multiply this constant
     * with the number of mobileStations in the network
     */
    public final static int TTLFactor=2;
    
    // Sending Station
    protected Station senderId; 
    //sequence number
    private int sequenceNo;
    //	package hop count
    private int hopCount;
    //	request number
    protected int requestId;
    // paquet size
    private int size; 
    //	life span
    private int ttl; 
    
    /**
     * constructor of an Package
     * @param r the Station
     * @param sn the sequence number
     * @param sc the hop count
     * @param s the size of the package
     * @param ri the request number
     * @param t duree de vie
     */
    public SMPackage(Station r,int sn, int sc, int ri, int s, int t){
	senderId = r; 
	sequenceNo = sn; 
	hopCount = sc; 
	requestId = ri;
	size = s; 
	ttl=t;
    }
    
    
    /**
     * constructor of a SMPackage
     * @param s SMPackage
     * this constuctor creates a SMPackage with the same
     * parameters that s
     */
    public SMPackage(SMPackage s){
	this.senderId=s.getSenderId();
	this.sequenceNo=s.getSequenceNo();
	this.hopCount=s.getHopCount();
	this.requestId=s.getRequestId();
	this.size=s.getSize();
	this.ttl=s.getTTL();
    }
    
    
    
    
    public String infoPackage(){
	
	String paquet = "Identifiant :"+ requestId + "\n"+
	    "source : "+senderId.getName()+"\n"+
	    "num seq : "+sequenceNo+"\n"+
	    "nb saut : "+hopCount+"\n"+
	    "size : "+size;
	return paquet;
    }
    
    /**
     * 
     * @return the SMPackage life span
     */
    public int getTTL(){
	return ttl;
    }
    
    /**
     *decrements the package life span
     */	
    public void decrementTTL(){
	this.ttl-=1;
    }
    
    /**
     * @return the SMPackage request number
     */
    public int getRequestId() {
	return requestId;
    }
    
    /**
     * @return the sending Station
     */
    public Station getSenderId() {
	return senderId;
    }
    
    /**
     * @return the sequence number
     */
    public int getSequenceNo() {
	return sequenceNo;
    }
    
    /**
     * @return the SMPackage size
     */
    public int getSize() {
	return size;
    }
    
    /**
     * @return the hop count
     */
    public int getHopCount() {
	return hopCount;
    }
    
    /**
     * 
     * @param i
     */
    public void setRequestId(int i) {
	requestId = i;
    }
    
    /**
     * @param Station
     */
    public void setSenderId(Station router) {
	senderId = router;
    }
    
    /**
     * @param i
     */
    public void setSequenceNo(int i) {
	sequenceNo = i;
    }
    
    /**
     * @param i
     */
    public void setSize(int i) {
	size = i;
    }
    
    /**
     * @param i
     */
    public void setHopCount(int i) {
	hopCount = i;
    }
    
    
    /**
     *increments the SMPackage life span
     */
    public void incrementHopCount(){
	this.hopCount++;
    }
    
}
